import React, { Suspense } from "react";
import { BrowserRouter, useRoutes } from "react-router-dom";
const Home = React.lazy(() => import("../view/home"));
const Login = React.lazy(() => import("../view/login"));
const List = React.lazy(() => import("../view/list"));
const MainLayout = React.lazy(() => import("../view/mainLayout"));

const RouterList = [
  {
    path: "/",
    element: <MainLayout></MainLayout>,
    children: [
      {
        path: "/",
        element: <Home></Home>,
      },
      {
        path: "/list",
        element: <List></List>,
      },
    ],
  },
  {
    path: "/login",
    element: <Login></Login>,
  },
];

const Router = () => {
	const RouterView = () => useRoutes(RouterList)
  return (
    <BrowserRouter>
      <Suspense>
				<RouterView></RouterView>
			</Suspense>
    </BrowserRouter>
  );
};

export default Router;
